import SwiftUI

// MARK: - Style Constants
struct StyleConstants {
    
    // MARK: - Colors
    struct Colors {
        // Primary colors - 高级黑白灰配色
        static let background = Color(.systemBackground)
        static let surfaceBackground = Color(.systemGray6)
        static let primaryText = Color(.label)
        static let secondaryText = Color(.secondaryLabel)
        
        // Brand colors - 优雅的强调色
        static let accent = Color("AccentColor") // 金色
        static let accentSecondary = Color.white
        
        // UI element colors
        static let cardBackground = Color(.systemBackground)
        static let cardBorder = Color(.systemGray4)
        static let buttonPrimary = Color(.label)
        static let buttonSecondary = Color(.systemGray2)
        
        // Camera UI colors
        static let cameraOverlay = Color.black.opacity(0.3)
        static let captureButton = Color.white
        static let captureButtonBorder = Color.white.opacity(0.8)
        
        // Filter UI colors
        static let filterSelected = Color.white
        static let filterUnselected = Color(.systemGray3)
        static let filterBackground = Color.black.opacity(0.4)
    }
    
    // MARK: - Typography
    struct Typography {
        // Title fonts
        static let largeTitle = Font.system(size: 34, weight: .bold, design: .default)
        static let title1 = Font.system(size: 28, weight: .bold, design: .default)
        static let title2 = Font.system(size: 22, weight: .semibold, design: .default)
        static let title3 = Font.system(size: 20, weight: .semibold, design: .default)
        
        // Body fonts
        static let body = Font.system(size: 17, weight: .regular, design: .default)
        static let bodyEmphasized = Font.system(size: 17, weight: .semibold, design: .default)
        static let callout = Font.system(size: 16, weight: .regular, design: .default)
        
        // UI fonts
        static let caption = Font.system(size: 12, weight: .regular, design: .default)
        static let caption2 = Font.system(size: 11, weight: .regular, design: .default)
        static let footnote = Font.system(size: 13, weight: .regular, design: .default)
    }
    
    // MARK: - Spacing
    struct Spacing {
        static let xs: CGFloat = 4
        static let sm: CGFloat = 8
        static let md: CGFloat = 16
        static let lg: CGFloat = 24
        static let xl: CGFloat = 32
        static let xxl: CGFloat = 48
    }
    
    // MARK: - Layout
    struct Layout {
        static let cornerRadius: CGFloat = 12
        static let smallCornerRadius: CGFloat = 8
        static let buttonHeight: CGFloat = 48
        static let minTouchTarget: CGFloat = 44
        static let separatorHeight: CGFloat = 1
        
        // Camera UI
        static let captureButtonSize: CGFloat = 80
        static let captureButtonBorderWidth: CGFloat = 4
        static let toolButtonSize: CGFloat = 44
        static let filterThumbnailSize: CGFloat = 64
    }
    
    // MARK: - Shadows
    struct Shadows {
        static let light = Shadow.light
        static let medium = Shadow.medium
        static let heavy = Shadow.heavy
    }
    
    struct Shadow {
        let color: Color
        let radius: CGFloat
        let x: CGFloat
        let y: CGFloat
        
        static let light = Shadow(color: .black.opacity(0.1), radius: 2, x: 0, y: 1)
        static let medium = Shadow(color: .black.opacity(0.15), radius: 4, x: 0, y: 2)
        static let heavy = Shadow(color: .black.opacity(0.25), radius: 8, x: 0, y: 4)
    }
    
    // MARK: - Animation
    struct Animation {
        static let quick = SwiftUI.Animation.easeInOut(duration: 0.2)
        static let smooth = SwiftUI.Animation.easeInOut(duration: 0.3)
        static let slow = SwiftUI.Animation.easeInOut(duration: 0.5)
        
        static let spring = SwiftUI.Animation.spring(response: 0.4, dampingFraction: 0.8)
        static let springBouncy = SwiftUI.Animation.spring(response: 0.3, dampingFraction: 0.6)
    }
}

// MARK: - View Extensions
extension View {
    func cardStyle() -> some View {
        self
            .background(StyleConstants.Colors.cardBackground)
            .cornerRadius(StyleConstants.Layout.cornerRadius)
            .shadow(
                color: StyleConstants.Shadows.light.color,
                radius: StyleConstants.Shadows.light.radius,
                x: StyleConstants.Shadows.light.x,
                y: StyleConstants.Shadows.light.y
            )
    }
    
    func buttonStyle(primary: Bool = false) -> some View {
        self
            .frame(height: StyleConstants.Layout.buttonHeight)
            .background(primary ? StyleConstants.Colors.buttonPrimary : StyleConstants.Colors.buttonSecondary)
            .foregroundColor(primary ? StyleConstants.Colors.accentSecondary : StyleConstants.Colors.primaryText)
            .cornerRadius(StyleConstants.Layout.cornerRadius)
            .font(StyleConstants.Typography.bodyEmphasized)
    }
}